﻿using System;
using System.IO;

namespace StoragePeriod.COMP
{
	public class FilePaths {
		/// <summary>
		/// 获得当前绝对路径
		/// </summary>
		/// <param name="strPath">指定的路径</param>
		/// <returns>绝对路径</returns>
		public static string GetMapPath(string strPath) {
			if (System.Web.HttpContext.Current != null)
				return System.Web.HttpContext.Current.Server.MapPath(strPath);
			else
				//非web程序引用
				return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
		}

      
        /// <summary>
        /// 获取一个新的文件路径
        /// </summary>
        /// <returns></returns>
        public static string GetNewFilePath()
        {
            return "/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
        }
        /// <summary>
        /// 获取一个新的文件名
        /// </summary>
        /// <param name="fileExt">文件扩展名(带.)</param>
        /// <param name="strEnd">文件名后缀</param>
        /// <returns></returns>
        public static string GetNewFileName(string fileExt,string strEnd="")
        {
            return DateTime.Now.Ticks.ToString() + strEnd + fileExt;
        }
	}
}
